#!/bin/bash

git rev-list --objects --all | grep -E `git verify-pack -v .git/objects/pack/*.idx | sort -k 3 -n | tail -10 | awk '{print$1}' | sed ':a;N;$!ba;s/\n/|/g'` >1.txt

for value in `cat 1.txt |awk '{print $2}'`
do
    # echo ${value}
    git log --pretty=oneline --branches -- ${value}
    git filter-branch --index-filter "git rm --cached --ignore-unmatch ${value}" -- --all

    rm -Rf .git/refs/original
    rm -Rf .git/logs/
    git reflog expire --expire=now --all
    git fsck --full --unreachable
    git repack -A -d
    git gc --aggressive --prune=now
done